/**
 * @file
 * @auth jinguangguo
 * @date 2017/1/18
 */

import Vue from 'vue';
import '../../common/commonFilter';
import '../../../grsc-base/directive/main';
import filter from '../../../grsc-base/util/filter';
import codeMap from '../../../grsc-base/common/codeMap';

// include相关
import '../../include/nav/nav';
import '../../include/footer/footer';

// alert & confirm & toast
import '../../../grsc-base/component/Toast/Toast';
import '../../../grsc-base/component/Alert/Alert';
import '../../../grsc-base/component/OffsetConfirm/OffsetConfirm';

window.CODE = codeMap;

// 东八区时间
Vue.prototype.ZONE = 8;
Vue.prototype.CURRENCY_RMB = 6.58;
window.CURRENCY_RMB = 6.58;
Vue.prototype.$USDCNY = 6.70;
window.$USDCNY = 6.70;
Vue.prototype.$$filter = filter;

Vue.prototype.reload = function () {
	// this.$router.go({
	//     path: this.$route.path,
	//     force: true
	// });
	// this.$router.go(0);
	window.location.reload();

};

let lang = window.location.pathname.split('/')[1]; // us / es
let href = window.location.href;

(function () {

	if (lang !== 'us' && lang !== 'es' && lang !== 'hk' && lang !== 'cn') {
		lang = 'cn'; // 默认使用cn
	}
	//人民币价格定位
	// add by jinguangguo @01/15
	// 如果当前路径具有/cn, 连接到对应的/hk目录下
	// if (lang === 'cn') {
	//     window.location.href = href.replace(`/cn/`, `/us/`);
	// }else if(lang === 'hk'){
	//     window.location.href = href.replace(`/hk/`, `/us/`);
	// }
	let Time = new Date().getTime();
	$.ajax({
		url: "/exchangeApi/configSymbol-Operate/getSymbolUsdtPrice",
		type: "GET",
		success: function (data) {
			// console.log(data)
			let USDTCNY = 6.70;
			let DIGITALUSD = 0;
			if (data.code == '100200') {
				USDTCNY = data.data.tether.replace('¥', '') * 1
				// DIGITALUSD = data.data.digitalusd.replace('¥', '') * 1
				if (USDTCNY != null && USDTCNY != 'null' && USDTCNY) {
					Vue.prototype.$USDCNY = USDTCNY;
					window.$USDCNY = USDTCNY;
					$(document).trigger('$$USDCNY', [USDTCNY]);
				}
				// if (DIGITALUSD != null && DIGITALUSD != 'null' && DIGITALUSD) {
				// 	Vue.prototype.$DIGITALUSD = DIGITALUSD;
				// 	window.$DIGITALUSD = DIGITALUSD;
				// 	$(document).trigger('$$DIGITALUSD', [DIGITALUSD]);
				// }
			}
			console.log(USDTCNY)
			// let USDCNY = data.Data[0][0][0] / 10000;
			// console.log(USDCNY)
			// Vue.prototype.$USDCNY = USDCNY;
			// window.$USDCNY = USDCNY;
			// $(document).trigger('$$USDCNY', [USDCNY]);
		}
	});

})();

let app = {
	DEBUG: false,
	isNeedStat: true, // 是否需要埋点统计    true正式环境 需要买点
	LANG: lang,
	isPayLocked: false, // 支付密码是否被锁定
	realAuth: { // 是否进行过实名认证
		requested: false,
		value: null
	},
	user: { // 当前登录用户的基本信息
		requested: false,
		value: null
	},
	abroad: true
};

if (href.indexOf('localhost') >= 0) {
	app.DEBUG = true;
}

// if (href.indexOf('localhost') >= 0 || href.indexOf('gdae2.dev.gpdax')>=0 ) {
//     app.isNeedStat = false;
// }

window.app = app;